<!--
 * @Author: ltl
 * @Date: 2023-8-23 15:59:56
 * @LastEditors: ltl
 * @LastEditTime: 2023-8-23 15:59:59
 * @Description: 个人中心页面头部-家辅
-->
<template>
  <div class="userVip" :style="{ backgroundColor: vipState ? '#ffdd9a' : '#ebedf0' }" @click="goVipOpen">
    <div class="userVip_left">
      <img class="crown" src="../../assets/images/user/crown.png" alt="">
      <div class="openVip" v-if="vipData.suitesState === '1' || vipData.suitesState === '2'">
        <span class="openVip_top">尊享{{ vipData.memberSuitesName }},{{ goReplace(vipData.disableTime) }}</span>
        <span class="openVip_bottom">已有{{ vipData.chargeCount }}家长为孩子开通优教会员</span>
      </div>
      <span class="noVip" v-else>您有VIP权益未解锁</span>
    </div>
    <div class="userVip_right" :style="{ color: vipState ? '#b18232' : '#676767' }">立即{{ vipState ? '查看' : '开通' }}<yj-mob-icon name="arrow" /></div>
  </div>
</template>

<script>
import { Icon } from 'yj-mob-ui';
import { externalLinkServices } from '@/api';
export default {
  name: 'vipParent',
  components: {
    [Icon.name]: Icon
  },
  data () {
    return {
    };
  },
  props: {
    vipData: {
      type: Object
    }
  },
  computed: {
    vipState () {
      return this.vipData.suitesState === '1' || this.vipData.suitesState === '2';
    }
  },
  methods: {
    goVipOpen () {
      window.location.href = externalLinkServices.vipList;
    },
    goReplace (data) {
      if (data) {
        return data.replace(/-/g, '/').substring(0, 10);
      } else {
        return '';
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.userVip{
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  height: 47px;
  line-height: 47px;
  margin: 99px 36px 0;
  border-radius: 12px 12px 0 0;
  padding: 0 6px 0 10px;
  box-sizing: border-box;
  .userVip_left{
    margin-top: 9px;
    font-size: 17px;
    font-weight: 600;
    color: #6c6c6c;
    display: flex;
    flex-direction: row;
    font-family: PingFangSC-Medium, PingFang SC, sans-serif;
    .crown{
      width: 30px;
      height: 30px;
    }
    .noVip{
      line-height: 32px;
    }
    .openVip{
      line-height: 16px;
      width: 178px;
      position: relative;
      font-size: 12px;
      margin-left: 3px;
      .openVip_top{
        font-size: 13px;
        font-weight: 600;
        color: #b17000;
      }
      .openVip_bottom{
        position: absolute;
        left: -17px;
        display: block;
        transform: scale(0.8);
        font-size: 12px;
        font-weight: 400;
        color: #b18232;
      }
    }
  }
  .userVip_right{
    margin-top: 2px;
    font-size: 15px;
  }
}
</style>
